package org.jeecg.modules.hc.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
public enum HcOrderStateEnum {
    WAIT("wait", "待付款"),
    PAY("pay", "已付款"),
    COMPLETED("completed", "已完成"),
    CANCELED("canceled", "已取消"),
    REFUNDING("refunding", "退款中"),
    NOTPAY("notpay", "未支付"),
    UNCOMPLETED("uncompleted", "已下单"),
    ;

    @EnumValue
    private final String value;
    @JsonValue
    private final String name;

    HcOrderStateEnum(String value, String name) {
        this.value = value;
        this.name = name;
    }

    public static HcOrderStateEnum get(String val) {
        Optional<HcOrderStateEnum> first = Arrays.stream(HcOrderStateEnum.values()).filter(e -> e.getValue().equals(val)).findFirst();
        return first.orElse(null);
    }

    public static HcOrderStateEnum getByName(String name) {
        Optional<HcOrderStateEnum> first = Arrays.stream(HcOrderStateEnum.values()).filter(e -> e.getName().equals(name)).findFirst();
        return first.orElse(null);
    }
}
